// custom-tab-bar/index.js
import  {storeBindingsBehavior}   from  'mobx-miniprogram-bindings'
import  {store} from  '../store/store'
Component({
   /**
    * 组件的属性列表
    */
   behaviors:[storeBindingsBehavior],
   storeBindings:{
      store,
      fields:{
         sum:'sum'
      },
      actions:{
         updaten1:"updaten1"
      }
   },
   observers:{
      "sum"(val){
         this.setData({
            "list[1].info":val
         })
      }
   },
   properties: {

   },

   /**
    * 组件的初始数据
    */
   data: {
      active: 0,
      "list": [
         {
           "pagePath": "/pages/aa/aa",
           "text": "首页",
           "iconPath": "/images/tabs/home.png",
           "selectedIconPath": "/images/tabs/home-active.png"
         },
         {
           "pagePath": "/pages/bb/bb",
           "text": "消息",
           "iconPath": "/images/tabs/message.png",
           "selectedIconPath": "/images/tabs/message-active.png",
           info: 10
         },
         {
           "pagePath": "/pages/index/index",
           "text": "联系我们",
           "iconPath": "/images/tabs/contact.png",
           "selectedIconPath": "/images/tabs/contact-active.png"
         }
       ]
   },

   /**
    * 组件的方法列表
    */
   methods: {
      onChange(event) {
         console.log(event.detail);
         // event.detail 的值为当前选中项的索引
         this.setData({
            active: event.detail
         });

         wx.switchTab({
           url: this.data.list[event.detail].pagePath,
         })
      },
   }
})